package http;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpCookie;

/**
 * @author zjf
 * @date 2020-09-11 16:27
 */
public class HttpSend {
    public static void main(String[] args) throws IOException {
        String requestURL = "http://118.190.124.69:7080/city-manage-api/bus/single_subroute/add?token=dongyx&murl=LineList";
        String requestBody = "{\"SUB_ROUTEID\":\"10003001\"}";
        // cookie  JSESSIONID=3CH7J6HUABTKAIFJ9CCBL4NMQBG8GHLH
        String cookie = "JSESSIONID=3CH7J6HUABTKAIFJ9CCBL4NMQBG8GHLH";


        HttpRequest post = HttpUtil.createPost(requestURL);
        post.body(requestBody);
        post.cookie(new HttpCookie("JSESSIONID", "3CH7J6HUABTKAIFJ9CCBL4NMQBG8GHLH"));
//        post.header("")
        HttpResponse execute = post.execute();

        BufferedReader br = new BufferedReader(new InputStreamReader(execute.bodyStream()));
        StringBuilder sb = new StringBuilder();
        String line = null;
        while ((line = br.readLine()) != null) {
            sb.append(line);
        }
        System.out.println("请求响应结果："+sb);

    }
}
